<%--
  Created by IntelliJ IDEA.
  User: zhangbin
  Date: 16/2/22
  Time: 21:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>上海263业务运营支撑系统</title>
    <link rel="stylesheet" type="text/css" href="/framework/jquery-easyui-1.4.4/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="/framework/jquery-easyui-1.4.4/themes/icon.css">
    <script type="text/javascript" src="/framework/jquery-easyui-1.4.4/jquery.min.js"></script>
    <script type="text/javascript" src="/framework/jquery-easyui-1.4.4/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/js/index.js"></script>
    <script type="text/javascript">
        function addTab(node){
            if($("#tabs").tabs("tabs").length>10){
                $.messager.confirm("提示","您打开的窗口太多了",function(r){
                    if(r){
                        var tabsss = $("#tabs").tabs("tabs");
                        for(var i = 0;i<tabsss.length;i++){
                            $("#tabs").tabs("close",$("#tabs").tabs("getTabIndex",tabsss[i]));
                        }
                    }
                });
            }
        }
        $(function() {
            //从后台来读取树形菜单
//            $("#menutree").tree({
//                animate : true,
//                id:'id',
//                text:'text',
//                lines : true,
//                fit:true,
//                url : 'admin_getAllRights',
//                onDblClick:function(node){
//                    if (!$("#tabs").tabs('exists', node.text)) {
//                        $("#tabs").tabs('add', {
//                            title : node.text,
//                            closable : true,
//                            content:"<iframe src='"+node.attributes.url+"' frameborder=0 width=100% height=100%/>"
//                        });
//                    }else{
//                        $('#tabs').tabs('select', node.text);
//                    }
//                }
//            });

            $('#editPassWin').window('close');
        });
        // 弹出信息窗口 title:标题 msgString:提示信息 msgType:信息类型 (error,info,question,warning)
        function msgShow(title, msgString, msgType) {
            $.messager.alert(title, msgString, msgType);
        }

        //修改密码
        function serverLoginPass() {

            var pass = $('#pass');
            var newpass = $('#txtNewPass');
            var repeatPass = $('#txtRePass');
            var flag=true;
            if (repeatPass.val() == '') {
                msgShow('系统提示', '请再一次输入密码！', 'warning');
                flag=false;
            }
            if (newpass.val() == '') {
                msgShow('系统提示', '请输入新密码！', 'warning');
                flag=false;
            }
            if (pass.val() == '') {
                msgShow('系统提示', '请输入原密码！', 'warning');
                flag=false;
            }
            if (newpass.val() != repeatPass.val()) {
                msgShow('系统提示', '两次密码不一至！请重新输入', 'warning');
                flag=false;
            }

            if(flag){
                $.ajax({
                    url:'admin_alterAdminPwd',
                    type:'post',
                    dataType:'text',
                    data:{'oldpassword':pass.val(),'newpassword':newpass.val(),'time':new Date()},
                    success:function(data){
                        if(data=='success'){
                            pass.val('');
                            newpass.val('');
                            repeatPass.val('');
                            $('#editPassWin').window('close');
                            showMessage("您的密码已成功修改~!");
                        }else{
                            msgShow('系统提示', data, 'warning');
                        }
                    }
                });
            }

        }
        function oo(){
            $('#editPassWin').window('open');
        }
        function dd(){
            $('#editPassWin').window('close');
        }

        //退出
        function loginout(){
            $.messager.confirm('确认对话框', '确认要退出本次登录吗？', function(r) {
                if (r) {
                    location='/logout';
                }
            });
        }
        function showMessage(message){
            $.messager.show({
                title:'温馨提示~',
                msg:message,
                showType:'show'
            });
        }
    </script>
</head>
<body class="easyui-layout">
<div data-options="region:'north'" split="true" border="false"
     style="overflow: hidden; height: 56px; background: #ffffff repeat-x center 50%; line-height: 40px; color: brown; font-family: Verdana, 微软雅黑, 黑体">
		<span style="float: right; padding-right: 20px;" class="head">欢迎，
			<span id="username">[<shiro:principal property="name"/>]</span>&nbsp;&nbsp;&nbsp;
            <span id="role">角色<shiro:principal property="roleNames"/></span>&nbsp;&nbsp;&nbsp;
            <a style="color: brown" href="javascript:oo()" id="editpass">修改密码</a>
            <a style="color: brown" href="javascript:loginout()" id="loginout">安全退出</a>
		</span>
		<span style="padding-left: 10px; font-size: 16px; font-style:italic;">
			<img src="images/logo.png" width="60" height="50" align="absmiddle" />
			业务运营支撑系统
		</span>
</div>
<div data-options="region:'south'" split="true" border="false"
     style="overflow: hidden; height: 30px; background: #ffffff repeat-x center 50%; line-height: 26px; color: burlywood; font-family: Verdana, 微软雅黑, 黑体">
		<span style="padding-left: 10px; font-size: 12px;">
			研发部全体同事感谢您的支持~！
		</span>
</div>
<div data-options="region:'west',title:'导航菜单',split:true"
     style="width: 160px;">
    <div id="menutree"  fit="true" data-options="border:false">
    </div>
</div>
<div data-options="region:'center',title:'',border:false"
     style="padding: 0px; background: #eee;">
    <div id="tabs" class="easyui-tabs" data-options="fit : true">
    </div>
</div>
<div id="editPassWin" class="easyui-window" title="修改密码" collapsible="false" minimizable="false"
     maximizable="false" icon="icon-save"  style="width: 310px; height: 200px; padding: 5px;
        background: #fafafa;">
    <div class="easyui-layout" fit="true">
        <div region="center" border="false" style="padding: 10px; background: #fff; border: 1px solid #ccc;">
            <table cellpadding=3 width="100%" class="table_form">
                <tr>
                    <td>原密码：</td>
                    <td><input id="pass" type="password" class="txt01" /></td>
                </tr>
                <tr>
                    <td>新密码：</td>
                    <td><input id="txtNewPass" type="password" class="txt01" /></td>
                </tr>
                <tr>
                    <td>确认密码：</td>
                    <td><input id="txtRePass" type="password" class="txt01" /></td>
                </tr>
            </table>
        </div>
        <div region="south" border="false" style="text-align: right; height: 30px; line-height: 30px;">
            <a id="btnPass" class="easyui-linkbutton" icon="icon-ok" href="javascript:serverLoginPass()" >
                确定</a> <a id="btnPassResult" class="easyui-linkbutton" icon="icon-cancel" href="javascript:dd()">取消</a>
        </div>
    </div>
</div>

</body>
</html>
